<template>
	<view class="">
		<view class="top" u-font-50>
			<text style="font-size: 40rpx;font-weight: bold;">我的投递</text>
		</view>
		<view class="lists">
      <view v-if="list==''">暂无投递信息</view>
			<u-swipe-action v-else :show="item.show" :index="index" v-for="(item, index) in list" :key="item.id" @click="click" @open="open" :options="options">
				<view class="item u-border-bottom">
					<view class="title-wrap u-font-50">
						{{ item.organization }}
					</view>
				</view>
				<u-line class="u-line" color="orange"></u-line>
			</u-swipe-action>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
     //      {
					// 	organization: '陈新元',
					// 	time: '2003060329', //学号
					// },
				],
				disabled: false,
				btnWidth: 180,
				show: false,
				options: [ ]
			};
		},
		onLoad() {
      
		},
    onReady() {
      let that = this
			//请求个人信息options
      console.log('onisok')
			uni.getStorage({
				key: 'token',
				success: function(res) {
					console.log(res.data);
					that.$request({
					  method: 'GET', // 默认GET
					  url: '/user/record',
					  header: {
              'Authorization': "Bearer " + res.data
            },
					}).then(res => {
					  // 成功后执行，具体格式待对完接口完善
            if (res.code == 200) {
              that.list = res.data
            }
					  console.log(res)
					}).catch(res => {
					  // 失败后执行
					})
				}
			})
    },
		methods: {
			click(index, index1) {
				if (index1 == 1) {
					this.list.splice(index, 1);
					this.$u.toast(`删除了第${index}个cell`);
				} else {
					this.list[index].show = false;
					this.$u.toast(`收藏成功`);
				}
			},
			// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
			open(index) {
				// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
				// 原本为'false'，再次设置为'false'会无效
				this.list[index].show = true;
				this.list.map((val, idx) => {
					if (index != idx) this.list[idx].show = false;
				})
			},
			goStu(id) {
				//这里做一个判断，从token里拿，如果为社团则跳到stuSt否则跳到stuOrg
				uni.navigateTo({
					url: url + '?id=' + id
				})
			},
			abab(e) {
				console.log('agd:' + e)
			}
		}
	};
</script>

<style lang="scss" scoped>
	body {
		height: 100vh;
	}

	.item {
		display: flex;
		padding: 20rpx;
	}

	image {
		width: 120rpx;
		flex: 0 0 120rpx;
		height: 120rpx;
		margin-right: 20rpx;
		border-radius: 12rpx;
	}

	#btn,
	#btn button {
		width: 400rpx;
	}

	.title {
		text-align: left;
		font-size: 28rpx;
		color: $u-content-color;
		margin-top: 20rpx;
	}

	.lists {
		padding: 20rpx;
		border-radius: 10rpx;
		height: 900rpx;
		margin: 60rpx;
		-webkit-box-shadow: 0px 3px 3px #c8c8c8;
		-moz-box-shadow: 0px 3px 3px #c8c8c8;
		box-shadow: 3px 3px 3px 3px #c8c8c8;
	}

	.top {
		width: 100%;
		height: 100px;
		border: .5px solid black;
		border-radius: 0 0 50% 50%/0 0 100% 100%;
		border-top: none;
		background-color: #f7c04a;
		text-align: center;
		line-height: 200rpx;
	}
</style>
